package 异常;

/*
public String getMessage():返回此 throwable 的详细消息字符串
public String toString():返回此可抛出的简短描述
public void printStarkTrace():把异常的错误信息输出在控制台
 */
public class ThrowableDemo {
    public static void main(String[] args) {
        System.out.println("开始");
        method();
        System.out.println("结束");
    }

    public static void method() {
        try {
            int[] arr = {1, 2, 3};
            System.out.println(arr[3]); //new ArrayIndexOutOfBoundsException()("xxx");
        } catch (ArrayIndexOutOfBoundsException e) {
//            e.printStackTrace();
//            System.out.println(e.getMessage())

            //public String toString():返回此可抛出的简短描述
            System.out.println(e.toString());//java.lang.ArrayIndexOutOfBoundsException: 3

            //public void printStarkTrace():把异常的错误信息输出在控制台
            e.printStackTrace();//最全面的输出错误信息
        }
    }
}
/*public class Throwable {
private String detailMessage;

   public Throwable(String Message)
   {
   detailMessage=Message
   }

   public String getMessage() {
        return detailMessage;
    }
}
 */
